using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Telerik.Web.UI;
using System.Drawing;

public partial class EditCompany : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        // Make sure user picks a file
        if (upload.UploadedFiles.Capacity > 0)
        {
            // Upload file never been easier when use telerik upload control ^_^        
            string fileExtension = upload.UploadedFiles[0].GetExtension();
            if (fileExtension == ".jpg" || fileExtension == ".bmp" || fileExtension == ".gif" || fileExtension == ".png")
            {
                string fileName = upload.UploadedFiles[0].GetName();
                string savedFolder = @"CoreLayout/ProductImages/";
                string realSaveFolder = Server.MapPath(savedFolder);
                string serverPath = realSaveFolder.Remove(17, 6);
                upload.TargetPhysicalFolder = serverPath;
                try
                {
                    //not need file stream or memory stream or etc ... just save :x
                    upload.UploadedFiles[0].SaveAs(serverPath + fileName, true);
                    lblUploadMessage.Text = "File " + fileName + " has been uploaded successfuly !";
                }
                catch (Exception ex)
                {
                    lblUploadMessage.Text = "Upload fail, please try again !";
                    throw ex;
                }
            }
            else
            {
                lblUploadMessage.Text = "Upload fail, please try again !";
            }
        }
        else
        {
            lblUploadMessage.Text = "Please choose image file to upload !";
        }
    }



    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
    }
}
